<template>
  <div>
    <h2>孩子一</h2>
    <h3>我的玩具有：{{toy1}}、{{toy2}}</h3>
    <button @click="giveToy(toy1)">给妹妹一个芭比娃娃</button>
    <button @click="giveToy(toy2)">给妹妹一个变形金刚</button>
  </div>
</template>

<script setup lang='ts' name="Child1">
import emitter from '@/utils/emitter';
import { ref, reactive, onBeforeUnmount, onUnmounted } from 'vue'

let toy1 = ref("芭比娃娃");
let toy2 = ref("变形金刚");

function giveToy(toy:string){
    emitter.emit("give",toy);
}


</script>


<style lang='scss' scoped>

</style>